package com.cn.wanxi.util.servlet;

import com.cn.wanxi.util.model.AboutContentModel;
import com.cn.wanxi.util.model.AboutNavModel;
import com.cn.wanxi.util.model.AnimationModel;
import com.cn.wanxi.util.service.impl.AboutNavService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/about")//外部访问后台的接口（地址）
public class AboutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doGet(req, resp);
        AboutNavService aboutNavService=new AboutNavService();
        HttpSession session = req.getSession();

//        页面内容
        List<AboutContentModel> aboutContentModels =aboutNavService.getabAboutContent();
        req.setAttribute("aboutContentModels",aboutContentModels);
//        页面滚动图片
        List<AnimationModel> animationModels =aboutNavService.getAnimationModel();
        req.setAttribute("animationModels",animationModels);
        gotoAbout(req,resp);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doPost(req, resp);
        gotoAbout(req,resp);
    }
    private void gotoAbout(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getRequestDispatcher("/jsp/about.jsp").forward(req,resp);
    };
}
